package com.truongnha.clienttn.business.service;

import android.content.Context;

import com.truongnha.clienttn.data.dao.CreateDatabase;
import com.truongnha.clienttn.data.dao.SavedAccountDAO;
import com.truongnha.clienttn.data.sao.LogoutSAO;

public class LogoutService {
	private boolean success = false;
	private LogoutSAO logoutSAO;
	private Context context;

	public LogoutService(Context context) {
		super();
		this.context = context;
	}

	public void logout(Boolean isDeleteAccount) {
		logoutSAO = new LogoutSAO();
		success = logoutSAO.isSuccess();
	}

	public void logout() {
		CreateDatabase db = new CreateDatabase(context);
		SavedAccountDAO savedAccountDAO = new SavedAccountDAO(db.open());
		savedAccountDAO.delete();
		db.close();

		logoutSAO = new LogoutSAO();
		success = logoutSAO.isSuccess();
	}

	public boolean isSuccess() {
		return success;
	}
}
